#pragma 
	template<class T>
	class share_ptr
	{
	public:
		share_ptr(T* ptr)
			:_ptr(ptr)
			, p_count(new int(1))
		{}

		share_ptr(const share_ptr<T>& ptr)
			:_ptr(ptr)
			, p_count(ptr)
		{
			(*p_count)++;
		}

		~share_ptr()
		{
			if (--(*p_count) == 0)
			{
				delete p_count;
				delete _ptr;
			}
		}
		share_ptr<int> operator=(const share_ptr<int>& sp)
		{
			if (_ptr != sp._ptr)
			{
				if (--(*p_count) == 0)
				{
					delete _ptr;
					delete p_count;
				}
				_ptr = sp._ptr;
				p_count = sp.p_count;
				(*p_count)++;

			}
		}
		T& operator*()
		{
			return *_ptr;
		}
		T* operator->()
		{
			return _ptr;
		}
	private:
		T* _ptr;
		int* p_count;
	};
